-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP implement clone method #37
base: master
Are you sure you want to change the base?
Conversation
return self.create(payload, **kwargs) | ||
except KeyError: | ||
raise NotImplementedError("Clone method isn't yet available for {} service." | ||
.format(self.service_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message isn't correlated to the actual error.
@@ -4,6 +4,7 @@ | |||
from thingy import Thingy | |||
|
|||
from appnexus.client import AppNexusClient, client, services_list | |||
from appnexus.clone_mixin import CloneMixin, clone_services_unrequired_fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a module just for this mixin. :)
@@ -172,6 +173,8 @@ def create_models(services_list): | |||
if service_name in ("AdQualityRule", "Advertiser", "Campaign", | |||
"Creative", "LineItem", "PaymentRule"): | |||
ancestors.append(ProfileMixin) | |||
if service_name in clone_services_unrequired_fields.keys(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if service_name in clone_services_unrequired_fields.keys(): | |
if service_name in ("Advertiser"): |
@@ -172,6 +173,8 @@ def create_models(services_list): | |||
if service_name in ("AdQualityRule", "Advertiser", "Campaign", | |||
"Creative", "LineItem", "PaymentRule"): | |||
ancestors.append(ProfileMixin) | |||
if service_name in clone_services_unrequired_fields.keys(): | |||
ancestors.append(CloneMixin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ancestors.append(CloneMixin) | |
ancestors.append(CloneMixin) | |
attrs["_unrequired_fields"] = clone_services_unrequired_fields[service_name] |
@@ -172,6 +173,8 @@ def create_models(services_list): | |||
if service_name in ("AdQualityRule", "Advertiser", "Campaign", | |||
"Creative", "LineItem", "PaymentRule"): | |||
ancestors.append(ProfileMixin) | |||
if service_name in clone_services_unrequired_fields.keys(): | |||
ancestors.append(CloneMixin) | |||
model = type(service_name, tuple(ancestors), {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model = type(service_name, tuple(ancestors), {}) | |
model = type(service_name, tuple(ancestors), attrs) |
try: | ||
payload = {} | ||
for field in self.__dict__.keys(): | ||
if field not in clone_services_unrequired_fields[type(self).__name__]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if field not in clone_services_unrequired_fields[type(self).__name__]: | |
if field not in self._unrequired_fields: |
No description provided.